package com.powernode.work.controller;

import com.powernode.commons.utils.ResponseData;
import com.powernode.work.bean.TranBean;
import com.powernode.work.service.TranService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("tran")
@Api(tags = "交易维护")
public class TranController {
    @Autowired
    private TranService service;
    @GetMapping
    @ApiOperation("分页显示所有的交易")
    public ResponseData page(@RequestParam(required = false,defaultValue = "1") Integer pageNum,
                             @RequestParam(required = false,defaultValue = "5") Integer pageSize, TranBean tran){
        return service.page(pageNum,pageSize,tran);
    }

    @GetMapping("getById")
    @ApiOperation("根据主键查询交易详情")
    public ResponseData getById(String id){
        return service.findById(id);
    }

    @PostMapping
    @ApiOperation("添加交易")
    public  ResponseData add(@RequestBody TranBean tran){
        return service.add(tran);
    }

    @PutMapping
    @ApiOperation("修改交易")
    public  ResponseData edit(@RequestBody TranBean tran){
        return service.modify(tran);
    }

    @GetMapping("getOriginById")
    @ApiOperation("根据主键获取原始数据")
    public ResponseData getOriginById(String id){
        return service.findOriginById(id);
    }
}
